#include "Rail.h"
#include <windows.h>
#include <GL/gl.h>

CRail::CRail(void): m_sizeOfRail(this, 0){}
CRail::CRail(float size):m_sizeOfRail(this, size){}

void CRail::doRender()
{
	glPushMatrix();
		drawCube(m_sizeOfRail);
		glTranslatef( -m_sizeOfRail, 0,0);
		drawCube(m_sizeOfRail);
		glTranslatef( 2*m_sizeOfRail,0, 0);
		drawCube(m_sizeOfRail);
	glPopMatrix();
}

void CRail::drawCube(float size)
{
	glPushMatrix();
	glTranslatef(-size/2, -size/2, -size/2);
	glBegin(GL_QUADS);
		
		glNormal3f(0, 0, 1);
		glVertex3f(0, 0, 0);
		glVertex3f(size, 0, 0);
		glVertex3f(size, size, 0);
		glVertex3f(0, size, 0);
		
		//ok
		glNormal3f(1, 0, 0);
		glVertex3f(size, size, 0);
		glVertex3f(size, 0, 0);
		glVertex3f(size, 0, size);
		glVertex3f(size, size, size);
		
		//ok
		glNormal3f(-1, 0, 0);
		glVertex3f(0, 0, 0);
		glVertex3f(0, size, 0);
		glVertex3f(0, size, size);
		glVertex3f(0, 0, size);
		
		glNormal3f(0, 0, -1);
		glVertex3f(0, size, size);
		glVertex3f(0, 0, size);
		glVertex3f(size, 0, size);
		glVertex3f(size, size, size);
		
		//ok
		glNormal3f(0, 1, 0);
		glVertex3f(0, size, size);
		glVertex3f(size, size, size);
		glVertex3f(size, size, 0);
		glVertex3f(0, size, 0);

		//ok
		glNormal3f(0, -1, 0);
		glVertex3f(0, 0, 0);
		glVertex3f(size, 0, 0);
		glVertex3f(size, 0, size);
		glVertex3f(0, 0, size);
			
	glEnd();
	glPopMatrix();
}
